<!DOCTYPE html>
<html>

<head>

    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">


    <title>ZDH 血源分析首页</title>
    <meta name="keywords" content="ZDH 血源分析首页">
    <meta name="description" content="ZDH 血源分析首页">

    <link rel="shortcut icon" href="img/favicon.ico">
    <link href="css/bootstrap.min.css?v=3.3.6" rel="stylesheet">
    <link href="css/font-awesome.css?v=4.4.0" rel="stylesheet">

    <link href="css/plugins/chosen/chosen.css" rel="stylesheet">

    <link href="css/animate.css" rel="stylesheet">
    <link href="css/style.css?v=4.1.0" rel="stylesheet">
    <link href="css/plugins/datetimepicker/datetimepicker.css" rel="stylesheet">
    <link href="css/plugins/bootstrap-table/bootstrap-table.min.css" rel="stylesheet">
    <link rel="stylesheet" type="text/css" href="css/jsplumb/style.css">
</head>

<body class="gray-bg">

<div class="wrapper wrapper-content animated fadeInRight">
    <div class="row">
    <div class="ibox float-e-margins">
        <div class="ibox-title">
            <h5>数据源查询</h5>
            <div class="ibox-tools">
                <a class="collapse-link">
                    <i class="fa fa-chevron-up"></i>
                </a>
                <a class="dropdown-toggle" data-toggle="dropdown" href="buttons.html#">
                    <i class="fa fa-eye"></i>
                </a>
                <ul class="dropdown-menu dropdown-user">
                    <li><a href="javascript:void(0);" onclick="getResourceDesc()">功能说明</a>
                    </li>
                </ul>
            </div>
        </div>
        <div class="ibox-content">

            <form role="form" class="form-inline" id="blood_source_form">
                <div class="form-group">
                    <div class="input-group">
                        <input id="input" name="input" type="text"
                               placeholder="数据源"
                               aria-required="true" class="form-control">
                    </div>
                    <input id="search" οnsubmit='return false' type="button" class="btn btn-primary form-control"
                           style="margin-bottom:0px" value="查询"/>
                </div>

            </form>

            <div class="row row-lg">
                <div class="col-sm-12">
                    <!-- Example Events -->
                    <div class="example-wrap">

                        <table id="exampleTableEvents" data-height="500" data-mobile-responsive="true">

                        </table>
                    </div>
                </div>
                <!-- End Example Events -->
            </div>
        </div>
    </div>

    </div>
</div>
<script src="js/zdh_common.js"></script>
<!-- 全局js -->
<script src="js/jquery.min.js?v=2.1.4"></script>
<script src="js/jquery-ui.custom.min.js?v=2.1.4"></script>
<script src="js/jquery-ui-1.10.4.min.js"></script>
<script src="js/bootstrap.min.js?v=3.3.6"></script>


<!-- 自定义js -->
<script src="js/content.js?v=1.0.0"></script>

<!-- Chosen -->
<script src="js/plugins/chosen/chosen.jquery.js"></script>


<script src="js/plugins/datetimepicker/bootstrap-datetimepicker.min.js"></script>

<script src="js/plugins/datetimepicker/bootstrap-datetimepicker.zh-CN.js"></script>

<!-- Bootstrap table -->
<script src="js/plugins/bootstrap-table/bootstrap-table.min.js"></script>
<script src="js/plugins/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
<script src="js/plugins/layer/laydate/laydate.js"></script>
<!-- layer javascript -->
<script src="js/plugins/layer/layer.min.js"></script>
<script type="text/javascript">

    function openTabPage(url, title) {
        var wpd = $(window.parent.document);
        var mainContent = wpd.find('.J_mainContent');
        var thisIframe = mainContent.find("iframe[data-id='" + url + "']");
        var pageTabs = wpd.find('.J_menuTabs .page-tabs-content ');
        pageTabs.find(".J_menuTab.active").removeClass("active");
        mainContent.find("iframe").css("display", "none");
        if (thisIframe.length > 0) {	// 选项卡已打开
            thisIframe.css("display", "inline");
            pageTabs.find(".J_menuTab[data-id='" + url + "']").addClass("active");
        } else {
            var menuItem = wpd.find("a.J_menuItem[href='" + url + "']");
            var dataIndex = title == undefined ? menuItem.attr("data-index") : '9999';
            var _title = title == undefined ? menuItem.find('.nav-label').text() : title;
            var iframe = '<iframe class="J_iframe" name="iframe' + dataIndex + '" width="100%" height="100%" src="' + url + '" frameborder="0" data-id="' + url
                + '" seamless="" style="display: inline;"></iframe>';
            pageTabs.append(
                ' <a href="javascript:;" class="J_menuTab active" data-id="' + url + '">' + _title + ' <i class="fa fa-times-circle"></i></a>');
            mainContent.append(iframe);
            //显示loading提示
            var loading = top.layer.load();
            mainContent.find('iframe:visible').load(function () {
                //iframe加载完成后隐藏loading提示
                top.layer.close(loading);
            });
        }

    }

</script>
<script>
    $(document).ready(function () {

        var url = location.search; //这一条语句获取了包括问号开始到参数的最后，不包括前面的路径
        var params = url.substr(1);//去掉问号
        var pa = params.split("&");
        var s = new Object();//定义一个全局变量-存储任务ID
        for (var i = 0; i < pa.length; i++) {
            s[pa[i].split("=")[0]] = unescape(pa[i].split("=")[1]);
        }

        var height=400;
        if($(document.body).height()*0.8>height){
            height=$(document.body).height()*0.8
        }
        $('#exampleTableEvents').attr("data-height",height);


        function getMyDate(str) {
            var oDate = new Date(str),
                oYear = oDate.getFullYear(),
                oMonth = oDate.getMonth() + 1,
                oDay = oDate.getDate(),
                oHour = oDate.getHours(),
                oMin = oDate.getMinutes(),
                oSen = oDate.getSeconds(),
                oTime = oYear + '-' + getzf(oMonth) + '-' + getzf(oDay) + " " + getzf(oHour) + ":" + getzf(oMin) + ":" + getzf(oSen);//最后拼接时间
            return oTime;
        };

        //补0操作
        function getzf(num) {
            if (parseInt(num) < 10) {
                num = '0' + num;
            }
            return num;
        }



        window.operateEvents = {
            'click #blood_source': function (e, value, row, index) {
                window.open(server_context+"/blood_source_detail_index.html?input=" + row.input+"&input_md5="+row.input_md5)
                //openTabPage("log_txt.html?job_id=" + row.job_id+"&task_log_id="+row.id + "&start_time=" + row.start_time + "&update_time=" + row.update_time, row.job_context + "日志")
            }
        };

        function operateFormatter(value, row, index) {
            return [
                ' <div class="btn-group" id="exampleTableEventsToolbar" role="group">' +
                ' <button id="blood_source" name="blood_source" type="button" class="btn btn-primary btn-sm" title="血源分析">血源分析\n' +
                '                                        <i class="fa fa-bold" aria-hidden="true"></i>\n' +
                '                                    </button>'
                +
                '</div>'

            ].join('');

        }

        $('#exampleTableEvents').bootstrapTable({
            method: 'POST',
            url: server_context+"/blood_source_list?" + $("#blood_source_form").serialize(),
            contentType: "application/json;charset=utf-8",
            dataType: "json",
            search: true,
            pagination: true,
            showRefresh: false,
            showToggle: true,
            showColumns: true,
            iconSize: 'outline',
            responseHandler:function (res) {
                if(res.code == "200"){
                    layer.msg(res.msg);
                    return res.result;
                }else{
                    layer.msg("未返回有效数据");
                    return ;
                }
            },
            toolbar: '#exampleTableEventsToolbar',
            icons: {
                refresh: 'glyphicon-repeat',
                toggle: 'glyphicon-list-alt',
                columns: 'glyphicon-list'
            },
            columns: [{
                checkbox: true,
                field: 'state',
                sortable: true
            }, {
                field: 'id',
                title: 'ID',
                visible: false
            }, {
                field: 'input_type',
                title: '数据源类型',
                sortable: true
            }, {
                field: 'input',
                title: '数据源',
                sortable: false,
                visible: true
            },{
                field: 'input_md5',
                title: '数据源标识',
                sortable: false,
                visible: true
            },{
                field: 'operate',
                title: '血源分析',
                events: operateEvents,//给按钮注册事件
                align: "center",
                valign: "middle",
                formatter: operateFormatter //表格中增加按钮
            }]
        });


        $('#search').click(function () {
            $('#exampleTableEvents').bootstrapTable('refresh', {
                url: server_context+"/blood_source_list?"+$("#blood_source_form").serialize(),
                contentType: "application/json;charset=utf-8",
                dataType: "json"
            });
        });

    });
</script>
</body>

</html>